#pragma once
#include "SkeletonJoint.h"

namespace Graphics{
	class AnimationController{
	public:
		AnimationController(std::vector<SkeletonJointPtr> &joints, Utility::Math::Matrix<4,4>& bindMatrix, std::string& name);

		void computeJointFrame(std::string& clipName, float time, std::vector<Utility::Math::Matrix<4,4>>& joints, RenderContext* context);
		void computeJointFrame(int clipId, float time, std::vector<Utility::Math::Matrix<4,4>>& joints, RenderContext* context);
		void computeJointFrame(int sourceClip,int targetClip,float sourceTime, float targetTime, float interpolate, std::vector<Utility::Math::Matrix<4,4>>& joints, RenderContext* context);

		void addAnimationClip(std::string &name, unsigned int id);

		SkeletonJointPtr			getJoint(std::string &name);
		std::vector<std::string>	getClips();
		std::vector<std::string>	getJointNames();
		int							getClipId(std::string& name);
		
		std::string& getName()											{ return m_name; }
		Utility::Math::Matrix<4,4>& getBindMatrix()						{ return m_bindMatrix; }
		std::vector<Utility::Math::Matrix<4,4>>& getBindPoseMatrices()	{ return m_bindPoseMatrices; }
	private:
		std::string m_name;
		std::vector<SkeletonJointPtr> m_joints;
		std::map<std::string,SkeletonJointPtr> m_jointNameMap;
		Utility::Math::Matrix<4,4> m_bindMatrix;

		std::vector<Utility::Math::Matrix<4,4>> m_bindPoseMatrices;
		std::map<std::string,unsigned int> m_animationClips;
	};
}

typedef boost::shared_ptr<Graphics::AnimationController> AnimationControllerPtr;